Skip to content

audio: dax: fixes regarding the results of coverity check - #11454

Open
checkupup wants to merge 1 commit into
thesofproject:mainfrom
checkupup:main_coverity_fixes
Open

checkupup wants to merge 1 commit into
thesofproject:mainfrom
checkupup:main_coverity_fixes

Conversation

@checkupup

Copy link
Copy Markdown
Contributor

Out-of-bounds access (ARRAY_VS_SINGLETON): original calls may treat proc_flags as an array.

@sofci

sofci commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

reply test this please to run this test once

@checkupup
checkupup marked this pull request as ready for review November 13, 2026 13:01
{
#ifdef __ZEPHYR__
int32_t bit = ffs(flag) - 1;
atomic_val_t mask = (atomic_val_t)flag;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@checkupup sorry not following the commit message here, not following what is being treated as an array by the compiler ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

atomic_*_bit functions use ATOMIC_ELEM macro to retrieve element:

// include/zephyr/sys/atomic.h
#define ATOMIC_BITS            (sizeof(atomic_val_t) * BITS_PER_BYTE)
#define ATOMIC_MASK(bit) BIT((unsigned long)(bit) & (ATOMIC_BITS - 1U))
#define ATOMIC_ELEM(addr, bit) ((addr) + ((bit) / ATOMIC_BITS))

static inline bool atomic_test_and_clear_bit(atomic_t *target, int bit)
{
	atomic_val_t mask = ATOMIC_MASK(bit);
	atomic_val_t old;

	old = atomic_and(ATOMIC_ELEM(target, bit), ~mask);

	return (old & mask) != 0;
}

It treats target pointer as an array pointer. In dax.c, if bit > sizeof(uint32_t), it may return &proc_flags + 1 address , resulting in out-of-bounds access.

I will update a commit message to describe the issue more clearly

Out-of-bounds access (ARRAY_VS_SINGLETON): atomic_*_bit functions use
ATOMIC_ELEM macro to retrieve element, which treats target pointer as
an array pointer. In dax.c, if bit > sizeof(uint32_t), it may return
an &proc_flags + 1 address , resulting in out-of-bounds access.

Signed-off-by: Jun Lai <junlai@dolby.com>
@intel-sofci

intel-sofci commented Nov 16, 2026 •

Copy link
Copy Markdown

PR 11454: test results

Run date: 2026-11-16 13:57 UTC

Tested commit: 20d278db673751045112ac6023d09cd06c4a853f

mtl pass rate lnl pass rate ptl pass rate wcl pass rate nvl pass rate

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

There are no active review issues for the Dolby DAX atomic-flag update.

No open issues 🎉

What changed in this PR

Addresses Coverity’s ARRAY_VS_SINGLETON warning in the Dolby DAX adapter by replacing bit-indexed atomic operations with word-level operations on the single proc_flags value.

Changes:

  • Uses an explicit mask for Zephyr flag reads, sets, and clears.
  • Preserves unrelated flags and returns the previous flag state for read-and-clear operations.
File Description
src/​audio/​module_adapter/​module/​dolby/​dax.c Replaces Zephyr bit-indexed atomic calls with masked word-level operations.

Review effort: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants